//
//  HomeNoticeCell.m
//  CarUser
//
//  Created by 王森林 on 2018/12/6.
//  Copyright © 2018年 王森林. All rights reserved.
//

#import "HomeNoticeCell.h"


@interface HomeNoticeCell()
@property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *subTitleLabel;
@property (nonatomic, strong) UIImageView *contentImageView;
@property (nonatomic, strong) UILabel *dateLabel;
@property (nonatomic, strong) NSDictionary *dataDict;
@end

@implementation HomeNoticeCell

-(void)createUIWithData
{
    [self.contentView  removeAllSubviews];
    [self.contentView addSubview:self.iconImageView];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.subTitleLabel];
    [self.contentView addSubview:self.contentImageView];
    [self.contentView addSubview:self.dateLabel];
  
    
    [self.iconImageView setImage:IMG(@"notice1")];
    self.titleLabel.text = [self.dataDict objectForKey:@"BT0000"];
    self. subTitleLabel.text =  [self.dataDict objectForKey:@"DNAME2"];
//    self.contentImageView.image = IMG(@"car_test1") ;
    //APPEND_URL(BASE_URL, [self.dataDict objectForKey:@"TPLJ00"])
//    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@uploadFiles/articleImg/%@",BASE_URL,[self.dataDict objectForKey:@"TPLJ00"]]]];
    [self.contentImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@uploadFiles/articleImg/%@",BASE_URL,[self.dataDict objectForKey:@"TPLJ00"]]] placeholderImage:IMG(@"car_test3")];
    self.dateLabel.text = [self.dataDict objectForKey:@"FBSJ01"];
    [self showSeparatorWithY:259.5];
    [self createConstraint];
//    NSLog(@"url%@",APPEND_URL(BASE_URL, [self.dataDict objectForKey:@"TPLJ00"]));
    
    
}

- (void)createConstraint
{
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(15);
        make.left.equalTo(self.contentView.mas_left).offset(15);
        make.width.mas_equalTo(40);
        make.height.mas_equalTo(40);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(18);
        make.left.equalTo(self.iconImageView.mas_right).offset(10);
        make.right.equalTo(self.contentView.mas_right).offset(-10);
    }];
    
    [self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(6);
        make.right.equalTo(self.contentView.mas_right).offset(-10);
        make.left.equalTo(self.iconImageView.mas_right).offset(10);
        make.height.mas_equalTo(14);
        
    }];
    
    [self.contentImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.subTitleLabel.mas_bottom).offset(15);
        make.right.equalTo(self.contentView.mas_right).offset(-15);
        make.left.equalTo(self.contentView.mas_left).offset(66);
        make.height.mas_equalTo(150);
    }];
    
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentImageView.mas_bottom).offset(10);
        make.height.mas_equalTo(14);
        make.left.equalTo(self.contentView.mas_left).offset(66);
         make.right.equalTo(self.contentView.mas_right).offset(-15);
    }];
    
    
    
}

- (void)setData:(id)data
{
    if (data){
        self.dataDict  = [NSDictionary dictionaryWithDictionary:data];
        [self createUIWithData];
    }
}

- (UIImageView *)iconImageView
{
    if (!_iconImageView) {
        _iconImageView = [UIImageView new];
        _iconImageView.layer.cornerRadius = 20;
        _iconImageView.layer.masksToBounds = YES;
        
    }
    return _iconImageView;
}


- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.textColor = Common_TextColor;
        _titleLabel.font = FONT_SIZE(14);
        _titleLabel.numberOfLines = 1;
    }
    return _titleLabel;
    
}

- (UILabel *)subTitleLabel
{
    if (!_subTitleLabel) {
        _subTitleLabel = [UILabel new];
        _subTitleLabel.textColor = Common_TextColor;
        _subTitleLabel.font = B_FONT_SIZE(12);
        _subTitleLabel.numberOfLines = 1;
    }
    return _subTitleLabel;
    
}



- (UIImageView *)contentImageView
{
    if (!_contentImageView) {
        _contentImageView = [UIImageView new];
        
    }
    return _contentImageView;
}

- (UILabel *)dateLabel
{
    if (!_dateLabel) {
        _dateLabel = [UILabel new];
        _dateLabel.textColor = RGB(195, 195, 195);
        _dateLabel.font = FONT_SIZE(12);
        _dateLabel.textAlignment = NSTextAlignmentLeft;
        _dateLabel.numberOfLines = 1;
    }
    return _dateLabel;
    
}
@end
